#ifndef _PCRE2LIB_H
#define _PCRE2LIB_H

#ifdef __cplusplus
extern "C" {
#endif

//callback function
//call this function when match
//head: buffer head
//list: app in-out parameter
typedef int (*regex_on_match)(char* head, 
	size_t item_offset, size_t item_len, void* list);

/* match 'regex' at str
 if find_all is 1, find all matches
 else only find first

 return match count
 return negatvie if error
*/
extern int regex_match(char* regex, char* str, unsigned int str_len, 
	int find_all,
	regex_on_match on_match,
	void* list);

/*
* regex replace
* reg_extend_flag = 0, not set PCRE2_SUBSTITUTE_EXTENDED
* reg_extend_flag = 1, set PCRE2_SUBSTITUTE_EXTENDED
* 
 return match count
 return negatvie if error
*/
extern int regex_replace(char* content, unsigned int content_len,
	char* regex_match, char* regex_replace,
	char* chg_content, size_t chg_len, int reg_extend_flag);

#ifdef __cplusplus
}
#endif
#endif
